/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.camachosanchez.gui.table;

import com.camachosanchez.util.Constantes;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
/**
 *
 * @author ZULLY
 */
public class RenderizadorTablaDespinches  implements TableCellRenderer {

    TableCellRenderer tcr;
    
    public RenderizadorTablaDespinches(TableCellRenderer tcr) {
        this.tcr = tcr;
    }
    
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        table.getTableHeader().setOpaque(false);
        JLabel etiqueta = new JLabel();
        etiqueta.setOpaque(true);
        etiqueta.setFont(new Font("Arial", Font.PLAIN, 12));
        if (value == null) {
            etiqueta.setText("");
        } else {
            String texto = (String) ("" + value);
            etiqueta.setText(texto.toUpperCase());
        }
        etiqueta.setBackground(Color.white);
//        if (column == 0) {
//            etiqueta.setBackground(new Color(100, 100, 100));
//        }
        if (column > 1 && column < 4) {
            etiqueta.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 4));
            etiqueta.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        } else {
            etiqueta.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        }
        if (column == 1 || column == 4) {
            etiqueta.setBackground(new Color(217, 229, 242));//no editables
        } else {
            etiqueta.setBackground(Color.white);
        }

//        if (isSelected) {
//            etiqueta.setBackground(new Color(255, 204, 51));
//            if (column == 0) {
//                etiqueta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/camachosanchez/recursos/16_check.png")));
//            }
//        }
        JTableHeader header = table.getTableHeader();
        header.setBackground(Constantes.CABECERA);
        header.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
//        header.setBorder(javax.swing.BorderFactory.createLineBorder(Color.black));
//        header.setFont(new Font("Arial Narrow", Font.PLAIN, 12));
        return etiqueta;
    }
    
}
